package com.system.integralserver.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    @Bean
    public Queue queue(){
        return new Queue("integralserver.test");
    }


    @Bean
    public DirectExchange defaultExchange() {
        //参数2 是否持久化，默认true
        //参数3 是否自动删除，默认false。为true时，broker关闭，将删除，并且可以通过关闭和重新打开连接来重新声明它。
        return new DirectExchange("HWX's exchange", false, true);
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue())
                .to(defaultExchange())
                .with("spring.*");
    }

}
